<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var factory = function (different,type){
            if (this instanceof factory){
                //公共属性
                this.context = '我是大家的内容'
                //this.different = different
                //公共fangfa
                this.show = function(){
                    return '我出现啦···'
                }
                return s = this[type](different,this.context)

            }else{
                return new factory(different,type)
            }
        }
        //差异处理
        factory.prototype = {
            java:function(different,context){
                
                (function(different) {
                    console.log('java' + context + different)
                })(different)
                
            },
            python:function(different,context){
                (function(different) {
                    console.log( 'python' + context  + different)
                })(different)
                
            },
            javascript:function(different,context){
                (function(different) {
                   console.log('javascript' + context  + different)
                })(different)
                
            },
            ui:function(different,context){
                (function(different) {
                    console.log('ui' + context  + different)
                })(different)
                
            },
            nodejs:function(different,context){
                
                (function(different) {
                    console.log('nodejs'+'----'+context+'----'+different)
                })(different)

                
            }
        }
        var text1 = new factory('require','nodejs')
        console.log(text1)
        var text2 = new factory('class','java')
        console.log(text2)
        var text3 = new factory('zip','python')
        console.log(text3)
    </script>
</body>
</html>